import { Application } from 'egg';
import * as pageFindPlugin from 'mongoose-paginate';
import { CheckStandPaymentType } from '../constants/index';
// 收银台订单
export default (app: Application) => {
  const mongoose = app.mongoose;
  const articleSchema = new mongoose.Schema({
    // 付款标题
    title: {
      type: String,
      required: true,
    },
    // 描述
    des: {
      type: String,
      required: true,
    },
    // 商品ID如果有的话
    productId: Object,
    // 付款类型
    paymentType: {
      type: String,
      enum: CheckStandPaymentType,
      required: true,
    },
    // 应付款金额
    paymentAmount: {
      type: Number,
      required: true,
    },
    // 实际付款金额
    actualAmount: {
      type: Number,
      required: true,
    },
    // 友帮币抵扣数量
    coinAmount: {
      type: Number,
      required: true,
    },
    // 支付id
    tradeNo: {
      type: Number,
      required: true,
    },
    // 支付三方id
    orderId: {
      type: String,
      required: true,
    },
    // 是否已经支付成功
    isPaid: {
      type: Boolean,
      required: true,
      default: false,
    },
  }, { timestamps: true });

  articleSchema.plugin(pageFindPlugin, {});
  return mongoose.model('Checkstand', articleSchema, 'checkstand');
};
